package com.fastCms.manager.bim.controller.api;


import com.fastCms.business.bim.manage.DataListenManageService;
import com.fastCms.business.bim.manage.DeviceManageService;
import com.fastCms.business.bim.pojo.po.AirPO;
import com.fastCms.business.bim.pojo.po.ChartPO;
import com.fastCms.business.bim.pojo.po.DateListenDeviceParamPO;
import com.fastCms.business.bim.pojo.po.DeviceParamPO;
import com.fastCms.business.bim.pojo.vo.*;
import com.fastCms.business.frame.pojo.PageParam;
import com.fastCms.business.frame.response.ApiResponse;
import com.fastCms.business.frame.response.ResponseUtil;
import com.fastCms.manager.frame.annotation.UserAccess;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 商品 前端控制器
 * </p>
 *
 * @author liusq
 * @since 2021-03-05
 */
@RestController
@RequestMapping("api/dataListen")
@Api(value = "ApiDataListenController", tags = "前端-监测设备相关接口")
@UserAccess
public class ApiDataListenController {

    @Autowired
    private DataListenManageService dataListenManageServiceImpl;

    @Autowired
    private DeviceManageService deviceManageServiceImpl;


    @ApiOperation(value = "首页大屏-实时环境数据", notes = "")
    @GetMapping("/factoryActual")
    public ApiResponse<FactoryActualVO> factoryActual() {
        ApiResponse<FactoryActualVO> factoryActual = dataListenManageServiceImpl.factoryActual();
        return factoryActual;
    }

    @ApiOperation(value = "首页大屏-环境标准数据", notes = "")
    @GetMapping("/standard")
    public ApiResponse<StandardDateListenVO> standard() {
        ApiResponse<StandardDateListenVO> nowAir = dataListenManageServiceImpl.standard();
        return nowAir;
    }

    @ApiOperation(value = "根据业务类型获取相关设备的信息", notes = "TSP/PM25/PM10")
    @GetMapping("/getListenDetailList/{busiType}")
    public ApiResponse<List<ListenDataDetailVO>> getListenDetailList(@PathVariable String busiType) {
        List<ListenDataDetailVO> result = deviceManageServiceImpl.getListenDetailList(busiType);
        return ResponseUtil.success(result);
    }

    @ApiOperation(value = "无组织监测设备管理-空气质量微站排名", notes = "PM25和PM10的排名")
    @GetMapping("/airRank")
    public ApiResponse<AirRankVO> airRank() {
        AirRankVO result = deviceManageServiceImpl.airRank();
        return ResponseUtil.success(result);
    }

    @ApiOperation(value = "无组织监测设备管理-空气质量微站台账", notes = "")
    @PostMapping("/airBill")
    public ApiResponse<PageInfo<AirBillVO>> airBill(@RequestBody PageParam<AirPO> pageParam) {
        PageInfo<AirBillVO> result = deviceManageServiceImpl.airBill(pageParam);
        return ResponseUtil.success(result);
    }


    @ApiOperation(value = "无组织监测设备管理-tsp质量排行", notes = "")
    @PostMapping("/tspRank")
    public ApiResponse<PageInfo<TspRankVO>> tspRank(@RequestBody PageParam pageParam) {
        PageInfo<TspRankVO> result = deviceManageServiceImpl.tspRank(pageParam);
        return ResponseUtil.success(result);
    }

    @ApiOperation(value = "无组织监测设备管理-监测点数量", notes = "")
    @GetMapping("/tspCount")
    public ApiResponse<Integer> tspCount() {
        Integer result = deviceManageServiceImpl.tspCount();
        return ResponseUtil.success(result);
    }

    @ApiOperation(value = "无组织监测设备管理-tsp台账", notes = "")
    @PostMapping("/tspBill")
    public ApiResponse<PageInfo<TspBillVO>> tspBill(@RequestBody PageParam<DateListenDeviceParamPO> deviceParam) {
        PageInfo<TspBillVO> result = deviceManageServiceImpl.tspBill(deviceParam);
        return ResponseUtil.success(result);
    }


    @ApiOperation(value = "无组织监测设备管理-监测设备管理-数量", notes = "")
    @GetMapping("/listenDeviceNum")
    public ApiResponse<ListenDeviceNumVO> listenDeviceNum() {
        ListenDeviceNumVO result = deviceManageServiceImpl.listenDeviceNum();
        return ResponseUtil.success(result);
    }


    @ApiOperation(value = "无组织监测设备管理-监测设备管理-列表", notes = "")
    @PostMapping("/listenDeviceList")
    public ApiResponse<PageInfo<DeviceVO>> listenDeviceList(@RequestBody PageParam<DeviceParamPO> param) {
        PageInfo<DeviceVO> result = deviceManageServiceImpl.listenDeviceList(param);
        return ResponseUtil.success(result);
    }

    @ApiOperation(value = "前端图表接口", notes = "")
    @PostMapping("/chartList")
    public ApiResponse<List<ChartVO>> chartList(@RequestBody ChartPO chartPO) {
        List<ChartVO> result = deviceManageServiceImpl.getChart(chartPO);
        return ResponseUtil.success(result);
    }




//    @ApiOperation(value = "环境标准数据", notes = "")
//    @GetMapping("/standard")
//    public ApiResponse<StandardDateListenVO> standard() {
//        ApiResponse<StandardDateListenVO> nowAir = dataListenManageServiceImpl.standard();
//        return nowAir;
//    }

}
